home *** CD-ROM | disk | FTP | other *** search
/ Practical Algorithms for Image Analysis / Practical Algorithms for Image Analysis.iso / TARFILE.GZ / tarfile / ch_5.4 / fitcrit / ww.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-11  |  4.8 KB  |  130 lines

  1. /* WW.H: include file for wing-walk programs */
  2.  
  3. #include <images.h>             /* image format information */
  4.  
  5. #define ABS(A) (((A) >= 0) ? (A): -(A))  /* integer absolute value */
  6. #define ABSF(A) (((A) >= 0.0) ? (A): -(A))  /* floating absolute value */
  7.  
  8. #define DIAG 1.4142135          /* diagonal dist between pixels */
  9.  
  10. /* distances are kept *100 to obtain 2 digit precision for diagonals */
  11. #define HORIZVERT 100           /* unit length of segment times 100 */
  12. #define DIAG100 141             /* unit diagonal distance times 100 */
  13.  
  14. #define MDFLT 5                 /* max length of corner curvature */
  15. #define LDFLT 20                /* min length of features */
  16. #define MMAX 100                /* max M-width (needed for THETASMTH */
  17.  
  18. #define MAXPERCODE 6            /* 3 coords per PCC * 2 no.s per coord */
  19. #define MAXBRPERNODE 4          /* maximum branches from a node */
  20.  
  21. /* node types */
  22. #define ENDCOORD -1
  23. #define BIFCOORD -2
  24. #define CROSSCOORD -3
  25. #define STARTCOORD -4
  26. #define LINEBRCOORD -5
  27. #define BIFBRCOORD -6
  28. #define CROSSBRCOORD -7
  29.  
  30. #define MAXADJEDGES 3           /* max adjacent edges to another edge */
  31.  
  32. /* wing-walk feature types */
  33. #define WWSTRT 1
  34. #define WWCORNER 2
  35. #define WWCURVE  3
  36. #define WWEND 0
  37.  
  38. #define EPSILON1 0.0            /* tolerance on min peak width */
  39. #define EPSILON2 0.0            /* tolerance on corner/curve arc length */
  40.  
  41. #define BORDERTHETA 50.0        /* flag (anything > PI) indicates that theta
  42.                                  * has not been calculated because border /*
  43.                                  * 
  44.                                  * /* curve sweep -- indicates if the curve arc sweeps <180, >180, =180,
  45.                                  * or an entire 360 degrees, ie a circle */
  46. #define CURVELT180 0
  47. #define CURVEGT180 1
  48. #define CURVEEQ180 2            /* semicircle */
  49. #define CURVEEQ360 3            /* circle */
  50.  
  51. /* Wing-Walk Structures */
  52.  
  53. struct wwPar {
  54.   long m,                       /* middle segment length */
  55.     l,                          /* total wing-walk length */
  56.     w;                          /* 'wing' length */
  57. };
  58.  
  59. /* coords in double floating precision  */
  60. /* already defined in images.h
  61.  * struct dpoint{
  62.  * double x, y;
  63.  * };
  64.  */
  65.  
  66. struct wwfeats {
  67.   struct point strt,            /* starting and ending coord.s of feature */
  68.     end;
  69.   struct dpoint center;         /* center of curvature for curve */
  70.   double radius;                /* radius of curvature (=0 for strt line) */
  71. };
  72.  
  73. struct edge {                   /* data indices between ends or jcts */
  74.   long iLow,                    /* low and high indices in data array */
  75.     iHigh;
  76. };
  77.  
  78. struct theta {                  /* theta plot */
  79.   double theta,                 /* theta curvature value */
  80.     length;                     /* arclength from beginning to current */
  81. };
  82.  
  83.  
  84. /* structures for feature linked list */
  85.  
  86. struct featNode {               /* feature nodes pointing to feature par.s */
  87.   int type;                     /* type of wing-walk feature */
  88.   struct dpoint intrsct;        /* intersection point of tangents to curve */
  89.   char *info;                   /* contains parameter information */
  90.   struct featNode *next,        /* next node */
  91.    *previous;                   /* previous node */
  92. };
  93.  
  94. struct featK {                  /* corner feature parameters */
  95.   struct point coord;           /* coordinate of corner feature */
  96. };
  97.  
  98. struct featC {                  /* curve feature parameters */
  99.   struct point trans1, trans2;  /* beginning and ending transition points */
  100.   struct dpoint center;         /* coord. of center of circle of curvature */
  101.   double radiusC;               /* radius of curvature */
  102.   short dirn;                   /* trans pts. in CCW order (1), or CW (-1) */
  103. };
  104.  
  105. /* structures for graph representation */
  106.  
  107. struct edgeList {               /* list of graph edges */
  108.   struct edge edge;             /* data indices of ends of edge */
  109.   long node1, node2;            /* index of start/end nodes, -1 if no node */
  110.   long adjEdge1[MAXADJEDGES],   /* edge indices of start and end adjacent */
  111.     adjEdge2[MAXADJEDGES],      /*   edges: +ve if entering, -ve if leaving */
  112.     nAdjEdge1, nAdjEdge2;       /* no. of start and end adjacent edges */
  113.   long length;                  /* length * 100 */
  114. };
  115.  
  116. struct nodeList {               /* list of graph nodes */
  117.   long type;                    /* node type */
  118.   struct point locn;            /* x,y location */
  119.   long incEdge[4],              /* edges incident to node */
  120.     nEdges;                     /* no. edges incident to node */
  121.   struct featNode *wwFeatPtr[2];  /* ptr to ww features in linked list */
  122.   long nWWFeatPtr;              /* no. of ww features pointed to */
  123. };
  124.  
  125.  
  126. struct strghtEdges {            /* edge list of adjacent straight edges */
  127.   long front, end;              /* straight edge at front and end of edge */
  128.   int flag;                     /* used for marking edge already counted */
  129. };
  130.